<?php
/**
 * File Name...: application\controllers\index.php
 * Framework...: Blackbird Framework
 * Author......: KnKill, 2010 (c) KnKill Corporation
 */



/**
 * @package Blackbird Framework
 * @subpackage Application Controllers
 * @since 0.1
 */
class Controller_Index extends Base_Controller
{

function __construct() {
    parent::preload(); 
}

function index() {
    $releases = $this->db->query('SELECT `id`, `artists`, `release`, `date`, `status` FROM `releases` ORDER BY `id` LIMIT 0, 5')->fetchAll();
    $most_waited = $this->db->query('SELECT `id`, `artists`, `release`, `date`, `status` FROM `releases` ORDER BY `vote` DESC LIMIT 0, 5')->fetchAll();
    
    // Раскладываем артистов через запятую
    for ($i = 0; $i < count($releases); $i++) {
        $releases[$i]['artists'] = str_replace('|||', ', ', $releases[$i]['artists']);
    }
    
    for ($i = 0; $i < count($most_waited); $i++) {
        $most_waited[$i]['artists'] = str_replace('|||', ', ', $most_waited[$i]['artists']);
    }
    
    $this->view->assign('title', 'Главная страница');
    $this->view->assign('releases', $releases);
    $this->view->assign('most_waited', $most_waited);
    $this->view->display('index.php');
}


function about() {
    $this->view->display('about.php', array('title' => 'О проекте'));
}

function contact() {
    $this->view->display('contact.php', array('title' => 'Связь'));
}

function login() {
    $this->view->display('login.php', array('title' => 'Вход в систему'));
}

// End Of File [index.php]
}